<?php

use think\facade\Route;

/** 商品 */
Route::group('product', function () {
    Route::get('list$', 'list');
    Route::get('recommend', 'recommend');
    Route::get('hotsearch', 'hotSearch');
    Route::group('<id>', function () {
        Route::get('$', 'detail');
    });
})->middleware(['withoutLogin'])->prefix('\app\mall\service\product\Product@');

Route::get('product/<id>/info', '\app\mall\logic\product\Product@getInfo')->pattern(['id' => '\d+'])->middleware(['withoutLogin'])->setOption('is_api', 0);

/** 订单 */
Route::group('order', function () {
    Route::get('fetch', 'fetchOrder');
    Route::post('submit', 'submitOrder');
})->prefix('\app\mall\service\product\Product@');

/** 后台管理接口 */
Route::group('admin', function () {
    Route::group('product', function () {
        Route::get('list', '@list');
        Route::get('recommend', '@recommend');
        Route::get('create', '@create');
        Route::post('create', '@create');
        Route::group('<id>', function () {
            Route::get('edit', '@edit');
            Route::put('edit$', '@edit');
            Route::delete('$', '@delete');
            Route::put('edit/<field>', '@editField');
        })->pattern(['id' => '\d+']);
        /** 批量操作 */
        Route::put('disables', '@disables');// 批量下架
        Route::put('enables', '@enables');// 批量上架
        Route::delete('deletes/<ids>', '@deletes')->pattern(['ids' => '[\d,]+']);// 批量删除
    })->prefix('\app\mall\service\product\admin\Product')->middleware(['adminRoute']);
});
